package com.riant.test3;

import org.jasypt.util.text.BasicTextEncryptor;

public class JasyptTest {
    private static BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
    private static String salt = "welcome";// 加密的密钥

    static {
        textEncryptor.setPassword(salt);
    }

    public static String encrypt(final String password) {

        return textEncryptor.encrypt(password);// 需要加密的密码
    }

    public static String decrypt(final String password) {

        return textEncryptor.decrypt(password);
    }

    public static void main(final String[] args) {

        String password = "123456";
        String encrypt = encrypt(password);
        System.out.println(encrypt);
        System.out.println(decrypt(encrypt));

    }
}
